home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Experimental BBS Explossion 3
/
Experimental BBS Explossion III.iso
/
sound
/
sndblst3.zip
/
SB.DOC
< prev
next >
Wrap
Text File
|
1993-10-22
|
5KB
|
162 lines
Programming the Sound Blaster ADC/DAC:
2x6h DSP Reset Port Write Only
2xAh DSP Read Data Port Read Only
2xCh DSP Write Data or Command Write
2xCh DSP Write Buffer Status (bit 7) Read
2xEh DSP Data Available Status Bit 7) Read Only
x = 1,2,3,4,5,6 for the Sound Blaster <= 1.5
x = 1,2,3,4,5,6 for the Sound Blaster Micro Channel Version
x = 2,4 for the Sound Blaster 2.0
x = 2,4 for the Sound Blaster Pro
Some DSP Commands:
10h Direct mode 8-bit DAC (single byte data transfer)
14h DMA mode 8-bit DAC
20h Direct mode 8-bit ADC (single byte data transfer)
24h DMA mode 8-bit ADC
40h Set Time Constant
48h Set Block Size
91h High Speed DMA mode 8-bit DAC
99h High Speed DMA mode 8-bit ADC
D1h Turn on Speaker
D3h Turn off Speaker
D0h Halt DMA in progress
D4h Continue DMA
To reset the DSP:
1. Write a 01h to port 2x6h
2. Wait for 3 microseconds
3. Write a 00h to port 2x6h
4. Read port 2xAh until a 0AAh is read (see below for how to read from 2xAh)
If there is no 0AAh after about 100 reads, abort and declare that there is no
Sound Blaster present (or error)
To write to the DSP (all writes to 2xCh MUST follow this procedure)
1. Read 2xCh until bit 7 is clear
2. Write to 2xCh
To read from the DSP (all reads from 2xAh MUST follow this procedure)
1. Read 2xEh until bit 7 is set
2. Read from 2xAh
Interrupts:
In DMA DAC and DMA ADC modes, a single interrupt will occur after the
block of data has been read/written. To clear the interrupt, read 2xEh
once (as well as clearing the PIC).
Ignoring Interrupts:
The interrupt can be ignored if you poll the DMAC (DMA Controller).
Once the DMAC reports a count of 0FFFFh the transfer is finished, read
2xEh once and you are finished.
Note to VESA/Local Bus Video users:
These video cards use DMA channel 1 which is the DMA channel used by
the Sound Blaster. Any video accesses will screw up the output of the
Sound Blaster.
Calculating the Time Constant:
Normal Speed:
Time Constant = 256 - (1,000,000 / sampling rate)
= 256 - (1,000,000 / 8,000 )
= 131
High Speed:
Time Constant = (MSByte of) 65536 - (256,000,000 / sampling rate)
= (MSByte of) 65536 - (256,000,000 / 44,100)
= (MSByte of) 59731
= (MSByte of) 0E953h
= 0E9h
Direct mode DAC:
1. Write a D1h to 2xCh
2. Write a 10h to 2xCh
3. Write the 8-bit data sample to 2xCh
4. Wait for the correct timing (must do your own timing)
Repeat steps 2-4 until end of data
5. Write a D3h to 2xCh
Normal speed DMA mode DAC:
1. Write a D1h to 2xCh
2. Setup Interrupt service routine
3. Write a 40h to 2xCh
4. Write Time Constant to 2xCh
5. Program the DMAC (DMA Controller)
6. Write 14h to 2xCh
7. Write the LSByte of Data Length - 1
8. Write the MSByte of Data Length - 1
9. Service Interrupt (may need to repeat steps 5-7 in the ISR)
10. Restore original Interrupt Service Routine
11. Write a D3h to 2xCh
Commands can be written to the DSP while waiting for the interrupt
High speed DMA mode DAC:
1. Write a D1h to 2xCh
2. Setup Interrupt service routine
3. Write a 40h to 2xCh
4. Write Time Constant to 2xCh
5. Program the DMAC (DMA Controller)
6. Write 48h to 2xCh
7. Write the LSByte of Data Length - 1
8. Write the MSByte of Data Length - 1
9. Write 91h to 2xCh
10. Service Interrupt (may need to repeat steps 5-7 in the ISR)
11. Restore original Interrupt Service Routine
12. Write a D3h to 2xCh
Commands CANNOT be written to the DSP while waiting for the interrupt
Resetting the DSP is the procedure used to halt DMA in progress
Direct mode ADC:
1. Write a 20h to 2xCh
2. Read the 8-bit data sample from 2xAh
3. Wait for the correct timing (must do your own timing)
Repeat steps 1-3 until finished
Normal speed DMA mode ADC:
1. Setup Interrupt service routine
2. Write a 40h to 2xCh
3. Write Time Constant to 2xCh
4. Program the DMAC (DMA Controller)
5. Write 24h to 2xCh
6. Write the LSByte of Data Length - 1
7. Write the MSByte of Data Length - 1
8. Service Interrupt (may need to repeat steps 5-7 in the ISR)
9. Restore original Interrupt Service Routine
Commands can be written to the DSP while waiting for the interrupt
High speed DMA mode ADC:
1. Setup Interrupt service routine
2. Write a 40h to 2xCh
3. Write Time Constant to 2xCh
4. Program the DMAC (DMA Controller)
5. Write 48h to 2xCh
6. Write the LSByte of Data Length - 1
7. Write the MSByte of Data Length - 1
8. Write 99h to 2xCh
9. Service Interrupt (may need to repeat steps 5-7 in the ISR)
10. Restore original Interrupt Service Routine
Commands CANNOT be written to the DSP while waiting for the interrupt
Resetting the DSP is the procedure used to halt DMA in progress